<?php
namespace App\Model\Examples;

use PhalApi\Model\NotORMModel as NotORM;

/**
 *文章管理
 */

class ArticleType extends NotORM {

    protected function getTableName($id) {
        return 'article_type';
    }
    //根据openid获得用户详情
    public function getTypeIDByName($name) {
        $total = $this->getORM()
            ->select('*')
            ->where('name', $name);
        return $total;
    }
    public function getListItems($page, $perpage,$word) {
        return $this->getORM()
            ->select('*')
            ->limit(($page - 1) * $perpage, $perpage)
            ->where('name LIKE ?', '%' . $word . '%')
            ->order('id asc')
            ->fetchAll();
    }

    public function getListTotal($word) {
        $total = $this->getORM()
            ->where('name LIKE ?', '%' . $word . '%')
            ->count('id');

        return intval($total);
    }

}
